﻿using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using ContactTracing.Core;

namespace ContactTracing.ViewModel
{
    public class Case
    {
        private double? _ageYears;
        private double? _age;

        public bool IsLocked { get; set; }
        public string RecordId { get; set; }
        public int UniqueKey { get; set; }
        public string ID { get; set; }
        public string Surname { get; set; }
        public string OtherNames { get; set; }
        public string EpiCaseDef { get; set; }
        public string RecordStatus { get; set; }
        public string Gender { get; set; }
        public string IsolationCurrent { get; set; }
        public double? Age
        {
            get { return this._age; }
            set
            {
                this._age = value;

                if (AgeUnit == AgeUnits.Years)
                {
                    AgeYears = Math.Round(this.Age.Value, 2);
                }
                else if (AgeUnit == AgeUnits.Months && Age.HasValue)
                {
                    double newAge = (Age.Value / 12);
                    AgeYears = Math.Round(newAge, 2);
                }
                //else if (AgeUnit == null) { throw new ApplicationException("Age unit cannot be null in Age setter."); } // form updated to force AgeUnit if Age has a value, so this is no longer needed
                else
                {
                    AgeYears = null;
                }
            }
        }

        public double? AgeYears
        {
            get
            {
                return _ageYears;
            }
            private set
            {
                this._ageYears = value;
            }
        }

        public AgeUnits? AgeUnit { get; set; }
        public DateTime? DateOnset { get; set; }
        public DateTime? DateReport { get; set; }
        public string HeadOfHousehold { get; set; }
        public string Village { get; set; }
        public string VillageOnset { get; set; }
        public string VillageHosp { get; set; }
        public string SubCounty { get; set; }
        public string Parish { get; set; }
        public string SubCountyOnset { get; set; }
        public string SubCountyHosp { get; set; }
        public string Country { get; set; }
        public string CountryOnset { get; set; }
        public string CountryHosp { get; set; }
        public string District { get; set; }
        public string DistrictOnset { get; set; }
        public string DistrictHosp { get; set; }
        public DateTime? DateIsolationCurrent { get; set; }
        public DateTime? DateDischargeIso { get; set; }
        public DateTime? DateDeath { get; set; }
        public bool DateDeathEst { get; set; }
        public bool DateOnsetEst { get; set; }
        public string DateOnsetEstExplain { get; set; }
        public DateTime? DateHospitalCurrentAdmit { get; set; }

        public DateTime? DateDeathCurrentOrFinal
        {
            get
            {
                if (DateDeath.HasValue) return DateDeath;
                if (DateDeath2.HasValue) return DateDeath2;
                else return null;
            }
        }
        
        public DateTime? DateOutcomeInfoCompleted { get; set; }
        public string BleedUnexplainedEver { get; set; }
        public string SpecifyBleeding { get; set; }
        public string HospitalDischarge { get; set; }
        public string HospitalDischargeDistrict { get; set; }
        public bool DateDischargeIsoEst { get; set; }
        public DateTime? DateDischargeHospital { get; set; }
        public bool DateDischargeHospitalEst { get; set; }
        public DateTime? DateDeath2 { get; set; }
        public bool DateDeath2Est { get; set; }
        public string DateDeath2EstSpecify { get; set; }
        public string PlaceDeath { get; set; }
        public string HospitalDeath { get; set; }
        public string PlaceDeathOther { get; set; }
        public string VillageDeath { get; set; }
        public string SubCountyDeath { get; set; }
        public string DistrictDeath { get; set; }
        public DateTime? DateFuneral { get; set; }
        public bool FuneralConductedFam { get; set; }
        public bool FuneralConductedOutbreakTeam { get; set; }
        public string VillageFuneral { get; set; }
        public string SubCountyFuneral { get; set; }
        public string DistrictFuneral { get; set; }

        public string OriginalID { get; set; }
        public string PhoneNumber { get; set; }
        public string PhoneOwner { get; set; }
        public string StatusReport { get; set; }
        public bool OccupationFarmer { get; set; }
        public bool OccupationButcher { get; set; }
        public bool OccupationHunter { get; set; }
        public bool OccupationMiner { get; set; }
        public bool OccupationReligious { get; set; }
        public bool OccupationHousewife { get; set; }
        public bool OccupationStudent { get; set; }
        public bool OccupationChild { get; set; }
        public bool OccupationBusinessman { get; set; }
        public bool OccupationTransporter { get; set; }
        //public bool OccupationHCW { get; set; }
        public bool OccupationTraditionalHealer { get; set; }
        public bool OccupationOther { get; set; }

        public string OccupationTransporterSpecify { get; set; }
        public string OccupationBusinessSpecify { get; set; }
        public string OccupationOtherSpecify { get; set; }
        public string OccupationHCWPosition { get; set; }
        public string OccupationHCWFacility { get; set; }

        public double? Latitude { get; set; }
        public double? Longitude { get; set; }

        public DateTime? DateOnsetLocalStart { get; set; }
        public DateTime? DateOnsetLocalEnd { get; set; }

        public string HospitalizedCurrent { get; set; }
        public string HospitalizedPast { get; set; }

        public DateTime? DateHospitalPastStart1 { get; set; }
        public DateTime? DateHospitalPastStart2 { get; set; }

        public DateTime? DateHospitalPastEnd1 { get; set; }
        public DateTime? DateHospitalPastEnd2 { get; set; }

        public string HospitalPast1 { get; set; }
        public string HospitalPast2 { get; set; }

        public string HospitalVillage1 { get; set; }
        public string HospitalVillage2 { get; set; }

        public string HospitalDistrict1 { get; set; }
        public string HospitalDistrict2 { get; set; }

        public string IsolationPast1 { get; set; }
        public string IsolationPast2 { get; set; }

        public string SymptomFever { get; set; }
        public double? SymptomFeverTemp { get; set; }
        public string SymptomFeverTempSource { get; set; }
        public string SymptomVomiting { get; set; }
        public string SymptomDiarrhea { get; set; }
        public string SymptomFatigue { get; set; }
        public string SymptomAnorexia { get; set; }
        public string SymptomAbdPain { get; set; }
        public string SymptomChestPain { get; set; }
        public string SymptomMusclePain { get; set; }
        public string SymptomJointPain { get; set; }
        public string SymptomHeadache { get; set; }
        public string SymptomCough { get; set; }
        public string SymptomDiffBreathe { get; set; }
        public string SymptomDiffSwallow { get; set; }
        public string SymptomSoreThroat { get; set; }
        public string SymptomJaundice { get; set; }
        public string SymptomConjunctivitis { get; set; }
        public string SymptomRash { get; set; }
        public string SymptomHiccups { get; set; }
        public string SymptomPainEyes { get; set; }
        public string SymptomUnconscious { get; set; }
        public string SymptomConfused { get; set; }
        public string SymptomOtherHemo { get; set; }
        public string SymptomOtherHemoSpecify { get; set; }

        public string SymptomBleedUnexplained { get; set; }
        public string SymptomBleedGums { get; set; }
        public string SymptomBleedInjectionSite { get; set; }
        public string SymptomNoseBleed { get; set; }
        public string SymptomBloodyStool { get; set; }
        public string SymptomBloodVomit { get; set; }
        public string SymptomDigestedBlood { get; set; }
        public string SymptomCoughBlood { get; set; }
        public string SymptomBleedVagina { get; set; }
        public string SymptomBruising { get; set; }
        public string SymptomBloodInUrine { get; set; }
        public string SymptomOtherNonHemorrhagic { get; set; }
        public string SymptomOtherNonHemorrhagicSpecify { get; set; }

        public string SymptomFeverFinal { get; set; }
        public double? SymptomFeverTempFinal { get; set; }
        public string SymptomFeverTempSourceFinal { get; set; }
        public string SymptomVomitingFinal { get; set; }
        public string SymptomDiarrheaFinal { get; set; }
        public string SymptomFatigueFinal { get; set; }
        public string SymptomAnorexiaFinal { get; set; }
        public string SymptomAbdPainFinal { get; set; }
        public string SymptomChestPainFinal { get; set; }
        public string SymptomMusclePainFinal { get; set; }
        public string SymptomJointPainFinal { get; set; }
        public string SymptomHeadacheFinal { get; set; }
        public string SymptomCoughFinal { get; set; }
        public string SymptomDiffBreatheFinal { get; set; }
        public string SymptomDiffSwallowFinal { get; set; }
        public string SymptomSoreThroatFinal { get; set; }
        public string SymptomJaundiceFinal { get; set; }
        public string SymptomConjunctivitisFinal { get; set; }
        public string SymptomRashFinal { get; set; }
        public string SymptomHiccupsFinal { get; set; }
        public string SymptomPainEyesFinal { get; set; }
        public string SymptomUnconsciousFinal { get; set; }
        public string SymptomConfusedFinal { get; set; }
        public string SymptomOtherHemoFinal { get; set; }
        public string SymptomOtherHemoFinalSpecify { get; set; }

        public string HadContact { get; set; }
        public string ContactName1 { get; set; }
        public string ContactName2 { get; set; }
        public string ContactName3 { get; set; }
        public string ContactRelation1 { get; set; }
        public string ContactRelation2 { get; set; }
        public string ContactRelation3 { get; set; }
        public DateTime? ContactStartDate1 { get; set; }
        public DateTime? ContactStartDate2 { get; set; }
        public DateTime? ContactStartDate3 { get; set; }
        public DateTime? ContactEndDate1 { get; set; }
        public DateTime? ContactEndDate2 { get; set; }
        public DateTime? ContactEndDate3 { get; set; }
        public bool ContactDate1Estimated { get; set; }
        public bool ContactDate2Estimated { get; set; }
        public bool ContactDate3Estimated { get; set; }
        public string ContactVillage1 { get; set; }
        public string ContactVillage2 { get; set; }
        public string ContactVillage3 { get; set; }
        public string ContactDistrict1 { get; set; }
        public string ContactDistrict2 { get; set; }
        public string ContactDistrict3 { get; set; }
        public string ContactCountry1 { get; set; }
        public string ContactCountry2 { get; set; }
        public string ContactCountry3 { get; set; }
        public string TypesOfContact1 { get; set; }
        public string TypesOfContact2 { get; set; }
        public string TypesOfContact3 { get; set; }
        public string ContactStatus1 { get; set; }
        public string ContactStatus2 { get; set; }
        public string ContactStatus3 { get; set; }
        public DateTime? ContactDeathDate1 { get; set; }
        public DateTime? ContactDeathDate2 { get; set; }
        public DateTime? ContactDeathDate3 { get; set; }

        public string AttendFuneral { get; set; }
        public string FuneralNameDeceased1 { get; set; }
        public string FuneralNameDeceased2 { get; set; }
        public string FuneralRelationDeceased1 { get; set; }
        public string FuneralRelationDeceased2 { get; set; }
        public DateTime? FuneralStartDate1 { get; set; }
        public DateTime? FuneralStartDate2 { get; set; }
        public DateTime? FuneralEndDate1 { get; set; }
        public DateTime? FuneralEndDate2 { get; set; }
        public string FuneralVillage1 { get; set; }
        public string FuneralVillage2 { get; set; }
        public string FuneralDistrict1 { get; set; }
        public string FuneralDistrict2 { get; set; }
        public string FuneralTouchBody1 { get; set; }
        public string FuneralTouchBody2 { get; set; }

        public string Travel { get; set; }
        public string TravelVillage { get; set; }
        public string TravelDistrict { get; set; }
        public DateTime? TravelStartDate { get; set; }
        public DateTime? TravelEndDate { get; set; }
        public bool TravelDateEstimated { get; set; }

        public string HospitalBeforeIll { get; set; }
        public string HospitalBeforeIllPatient { get; set; }
        public string HospitalBeforeIllHospitalName { get; set; }
        public string HospitalBeforeIllVillage { get; set; }
        public string HospitalBeforeIllDistrict { get; set; }
        public DateTime? HospitalBeforeIllStartDate { get; set; }
        public DateTime? HospitalBeforeIllEndDate { get; set; }
        public bool HospitalBeforeIllDateEstimated { get; set; }

        public string TraditionalHealer { get; set; }
        public string TraditionalHealerName { get; set; }
        public string TraditionalHealerVillage { get; set; }
        public string TraditionalHealerDistrict { get; set; }
        public DateTime? TraditionalHealerDate { get; set; }
        public bool TraditionalHealerDateEstimated { get; set; }

        public string Animals { get; set; }
        public bool AnimalBats { get; set; }
        public bool AnimalPrimates { get; set; }
        public bool AnimalRodents { get; set; }
        public bool AnimalPigs { get; set; }
        public bool AnimalBirds { get; set; }
        public bool AnimalCows { get; set; }
        public bool AnimalOther { get; set; }

        public string AnimalBatsStatus { get; set; }
        public string AnimalPrimatesStatus { get; set; }
        public string AnimalRodentsStatus { get; set; }
        public string AnimalPigsStatus { get; set; }
        public string AnimalBirdsStatus { get; set; }
        public string AnimalCowsStatus { get; set; }
        public string AnimalOtherStatus { get; set; }
        public string AnimalOtherComment { get; set; }

        public string BittenTick { get; set; }

        public string InterviewerName { get; set; }
        public string InterviewerPhone { get; set; }
        public string InterviewerEmail { get; set; }
        public string InterviewerPosition { get; set; }
        public string InterviewerDistrict { get; set; }
        public string InterviewerHealthFacility { get; set; }
        public string InterviewerInfoProvidedBy { get; set; }
        public string ProxyName { get; set; }
        public string ProxyRelation { get; set; }

        public string CurrentStatus { get; set; }
        public string FinalStatus { get; set; }
        public string FinalLabClass { get; set; }
        public bool IsContact { get; set; }
        public bool? IsHCW { get; set; }
        public string PlaceOfDeath { get; set; }
        public string CurrentHospital { get; set; }

        public string CommentsOnThisPatient { get; set; }

        public DateTime? DateLastLabSampleTested { get; set; }
        public DateTime? DateLastLabSampleCollected { get; set; }
        public string LastSampleInterpretation { get; set; }
        public string LastSamplePCRResult { get; set; }

        public string IsContactSymbol
        {
            get
            {
                if (IsContact)
                {
                    return "‼";
                }
                else
                {
                    return String.Empty;
                }
            }
        }

        public Case()
        {
            IsLocked = false;
            ID = String.Empty;
            Surname = String.Empty;
            OtherNames = String.Empty;
            EpiCaseDef = String.Empty;
            RecordStatus = String.Empty;
            Gender = String.Empty;
            IsolationCurrent = String.Empty;
            Village = String.Empty;
            SubCounty = String.Empty;
            SubCountyOnset = String.Empty;
            Country = String.Empty;
            CountryOnset = String.Empty;
            CountryHosp = String.Empty;
            District = String.Empty;
            DistrictOnset = String.Empty;
            CurrentStatus = String.Empty;
            FinalStatus = String.Empty;
            FinalLabClass = String.Empty;
            PlaceOfDeath = String.Empty;
            LastSampleInterpretation = String.Empty;
            LastSamplePCRResult = String.Empty;
            CurrentHospital = String.Empty;

            OriginalID = String.Empty;

            DateHospitalCurrentAdmit = null;

            DateOutcomeInfoCompleted = null;
            BleedUnexplainedEver = String.Empty;
            SpecifyBleeding = String.Empty;
            HospitalDischarge = String.Empty;
            HospitalDischargeDistrict = String.Empty;
            DateDischargeIsoEst = false;
            DateDischargeHospital = null;
            DateDischargeHospitalEst = false;
            DateDeath2 = null;
            DateDeathEst = false;
            DateOnsetEst = false;
            DateDeath2Est = false;
            DateDeath2EstSpecify = String.Empty;
            PlaceDeath = String.Empty;
            HospitalDeath = String.Empty;
            PlaceDeathOther = String.Empty;
            VillageDeath = String.Empty;
            SubCountyDeath = String.Empty;
            DistrictDeath = String.Empty;
            DateFuneral = null;
            FuneralConductedFam = false;
            FuneralConductedOutbreakTeam = false;
            VillageFuneral = String.Empty;
            SubCountyFuneral = String.Empty;
            DistrictFuneral = String.Empty;

            SymptomFever = String.Empty;
            SymptomFeverTemp = null;
            SymptomFeverTempSource = String.Empty;
            SymptomVomiting = String.Empty;
            SymptomDiarrhea = String.Empty;
            SymptomFatigue = String.Empty;
            SymptomAnorexia = String.Empty;
            SymptomAbdPain = String.Empty;
            SymptomChestPain = String.Empty;
            SymptomMusclePain = String.Empty;
            SymptomJointPain = String.Empty;
            SymptomHeadache = String.Empty;
            SymptomCough = String.Empty;
            SymptomDiffBreathe = String.Empty;
            SymptomDiffSwallow = String.Empty;
            SymptomSoreThroat = String.Empty;
            SymptomJaundice = String.Empty;
            SymptomConjunctivitis = String.Empty;
            SymptomRash = String.Empty;
            SymptomHiccups = String.Empty;
            SymptomPainEyes = String.Empty;
            SymptomUnconscious = String.Empty;
            SymptomConfused = String.Empty;
            SymptomOtherHemo = String.Empty;
            SymptomOtherHemoSpecify = String.Empty;

            SymptomFeverFinal = String.Empty;
            SymptomFeverTempFinal = null;
            SymptomFeverTempSourceFinal = String.Empty;
            SymptomVomitingFinal = String.Empty;
            SymptomDiarrheaFinal = String.Empty;
            SymptomFatigueFinal = String.Empty;
            SymptomAnorexiaFinal = String.Empty;
            SymptomAbdPainFinal = String.Empty;
            SymptomChestPainFinal = String.Empty;
            SymptomMusclePainFinal = String.Empty;
            SymptomJointPainFinal = String.Empty;
            SymptomHeadacheFinal = String.Empty;
            SymptomCoughFinal = String.Empty;
            SymptomDiffBreatheFinal = String.Empty;
            SymptomDiffSwallowFinal = String.Empty;
            SymptomSoreThroatFinal = String.Empty;
            SymptomJaundiceFinal = String.Empty;
            SymptomConjunctivitisFinal = String.Empty;
            SymptomRashFinal = String.Empty;
            SymptomHiccupsFinal = String.Empty;
            SymptomPainEyesFinal = String.Empty;
            SymptomUnconsciousFinal = String.Empty;
            SymptomConfusedFinal = String.Empty;
            SymptomOtherHemoFinal = String.Empty;
            SymptomOtherHemoFinalSpecify = String.Empty;
        }
    }
}
